#include<bits/stdc++.h>
#include<map>
using namespace std;
typedef long long ll;
const ll N=1e6;
ll HarryPotterHashRand(const char *OriginalString) {
    char newString[0x3f3f];
    ll HashMOD = 101411234562527ll;
    memset(newString, 0, sizeof(newString));
    if (strlen(OriginalString) > 0x3f3e) return ((ll)(0xffffffff) - strlen(OriginalString));
    strcpy(newString + 1, OriginalString);
    ll seed = 111111111111111ll;
    for (int i = 1; newString[i] > 0; ++ i) {
        seed ^= (ll)(newString[i]) << 26;
        seed = ((seed << 1) + (seed << 2)) + (((ll)(newString[i]) << 34) * 10ll);
        seed *= newString[i] * 0xf;
        seed = (seed + HashMOD) % HashMOD;
    }
    return seed;
}
ll a[N]={0},g[N]={0};
map<ll,string> M;
map<ll,ll> Q;
int main()
{
	char s[1025]="";
	ll n,k,c,l=0,t=0,x=0,y=0;
	scanf("%lld%lld%lld",&n,&k,&c);
	getchar();
	for(ll i=0;i<c;++i){
        scanf("%lld",g+i);
        if(!i) a[i]=g[i];
		else a[i]=a[i-1]+g[i];
		std::cout << a[i] << " " << std::endl;
	}
	while(!g[l]) ++l;
	for(ll i=0;i<n;++i){
		scanf(" %s",s);
		ll harry=HarryPotterHashRand(s);
		string str=s;
		M[harry]=str;
		Q[harry]=l+1;
        
		++x;std::cout << l + 1 << " " << x << std::endl;
		while (x>a[l]){
			++l;
		}
	}
	for(ll i=0;i<k;++i){
		ll num;
		scanf("%lld",&num);
		printf("%lld %s\n",Q[num],M[num].c_str());
	}
}